package com.example.demo.common.code;

import com.example.demo.common.exception.YuException;
import org.apache.commons.lang3.StringUtils;

import java.util.Objects;
public class PlatStandardCode {
    private String alias;
    private String basicCode;
    private String basicDesc;
    private String executeFlag;
    private String subCode;
    private String subDesc;

    public PlatStandardCode(String alias, BasicCode basicCode, String subCode, String subDesc) {
        this(alias, basicCode.getCode(), basicCode.getCodeDesc(), subCode, subDesc, basicCode.getFlag().getCode());
    }

    public PlatStandardCode(String alias, String basicCode, String basicDesc, String subCode, String subDesc, String executeFlag) {
        if (!StringUtils.isEmpty(alias) && !StringUtils.isEmpty(basicCode) && !StringUtils.isEmpty(executeFlag)) {
            this.alias = alias;
            this.basicCode = basicCode;
            this.basicDesc = basicDesc;
            this.subCode = subCode;
            this.subDesc = subDesc;
            this.executeFlag = executeFlag;
        } else {
            throw new YuException(BasicCode.PARAMS_MISSING.getCode(),BasicCode.PARAMS_MISSING.getCodeDesc());
        }
    }

    public boolean equals(Object o) {
        if (this == o) {
            return true;
        } else if (o != null && this.getClass() == o.getClass()) {
            PlatStandardCode that = (PlatStandardCode)o;
            return Objects.equals(this.alias, that.alias) && Objects.equals(this.basicCode, that.basicCode) && Objects.equals(this.subCode, that.subCode);
        } else {
            return false;
        }
    }

    public int hashCode() {
        return Objects.hash(new Object[]{this.alias, this.basicCode, this.executeFlag, this.subCode});
    }

    public String toString() {
        return "PlatStandardCode{alias='" + this.alias + '\'' + ", basicCode='" + this.basicCode + '\'' + ", basicDesc='" + this.basicDesc + '\'' + ", executeFlag='" + this.executeFlag + '\'' + ", subCode='" + this.subCode + '\'' + ", subDesc='" + this.subDesc + '\'' + '}';
    }

    public String getAlias() {
        return this.alias;
    }

    public String getBasicCode() {
        return this.basicCode;
    }

    public String getBasicDesc() {
        return this.basicDesc;
    }

    public String getExecuteFlag() {
        return this.executeFlag;
    }

    public String getSubCode() {
        return this.subCode;
    }

    public String getSubDesc() {
        return this.subDesc;
    }
}
